import 'package:flutter/material.dart';
import 'package:chathouse/public/Config.dart';

// 数据页面
// ignore: must_be_immutable
class EmptyPage extends StatefulWidget {
  VoidCallback? emptyRetry; //空数据事件处理
  String? imgName;
  String? tipTitle;
  String? actionTitle;
  final Color backgroundColor;
  final bool isShowRetryBtn;
  final double marginTop;

  EmptyPage(
      {Key? key,
      this.emptyRetry,
      this.imgName,
      this.tipTitle,
      this.actionTitle,
      this.backgroundColor = Colors.white,
      this.isShowRetryBtn = true,
      this.marginTop = 135})
      : super(key: key);

  @override
  EmptyStatePage createState() => EmptyStatePage();
}

class EmptyStatePage extends State<EmptyPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children:[Container(
          color: widget.backgroundColor,
          constraints: const BoxConstraints.expand(),
          child: Center(

            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Image.asset(
                  widget.imgName ?? Res.image_empty,
                  width: 180,
                  height: 140,
                ),
                Text(
                  widget.tipTitle ?? '暫無可展示的數據',
                  style: const TextStyle(
                      color:Styles.c_666, fontSize: Styles.f18,fontWeight: FontWeight.w500),
                ),
                const SizedBox(
                  height: 20,
                ),
                Visibility(
                    visible: widget.emptyRetry != null,
                    child: InkWell(
                      onTap: widget.emptyRetry,
                      child: Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(4),
                            color: Styles.mainColor),
                        width: 72,
                        height: 32,
                        alignment: Alignment.center,
                        child: Text(
                          widget.actionTitle ?? "退出",
                          style: const TextStyle(color: Colors.white,fontSize: 14),
                        ),
                      ),
                    ))
              ],
            ),
          ),
        )],
      ),
    );
  }
}
